/**
  * Author: Mei
  * Date: 2021-01-10 19:19
  * Description: 
  *
  */
#include "../head.h"
#include "../rapidjson/document.h"
#include "../rapidjson/writer.h"
#include "../rapidjson/stringbuffer.h"

using namespace rapidjson;

int main() {
    // 1. Parse a JSON string into DOM.
    const char *json = "{\"project\":\"rapidjson\",\"stars\":10}";
    string str = R"kk(\\\aaa\)kk";
    cout << str << endl;
    Document d;
    d.Parse(json);

    // 2. Modify it by DOM.
    Value &s = d["stars"];
    Value &s1 = d["project"];
    assert(d.HasMember("project"));
    assert(d["project"].IsString());
    cout << s.GetInt() << endl;
    cout << s1.GetString() << endl;
    s.SetInt(s.GetInt() + 1);

    // 3. Stringify the DOM
    StringBuffer buffer;
    Writer<StringBuffer> writer(buffer);
    d.Accept(writer);

    std::cout << buffer.GetString() << std::endl;


    return 0;
}